#include <iostream>
#include <string>
#include <cctype>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> nums(n);
    for (int i = 0; i < n; ++i)
        cin >> nums[i];

    vector<long long> dp(n + 1, 0);
    for (int i = 1; i < n + 1; ++i)
        dp[i] = nums[i - 1] + dp[i - 1];

    int l, r;
    while (m--)
    {
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }

    return 0;
}

int main3()
{
    int n, m;
    cin >> n >> m;
    vector<vector<char>> arr(n, vector<char>(m));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> arr[i][j];

    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    unordered_map<char, int> hash;
    hash['l'] = 4, hash['o'] = 3, hash['v'] = 2, hash['e'] = 1;
    for (int i = 1; i < n + 1; ++i)
    {
        for (int j = 1; j < m + 1; ++j)
        {
            dp[i][j] = hash[arr[i - 1][j - 1]] + max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    cout << dp[n][m] << endl;

    return 0;
}

class Solution {
public:
    bool isHaveOne(vector<vector<char>>& grid, int i2, int j2)
    {
        if (grid[i2][j2] == '1')
            return true;
        return false;
    }

    void ChangeGrid(vector<vector<char>>& grid, vector<vector<char>>& next_grid, int i1, int j1)
    {
        next_grid[i1][j1] = '0';
        grid = next_grid;
        if (j1 + 1 < grid[0].size() && isHaveOne(grid, i1, j1 + 1))
            ChangeGrid(grid, next_grid, i1, j1 + 1);
        if (j1 - 1 >= 0 && isHaveOne(grid, i1, j1 - 1))
            ChangeGrid(grid, next_grid, i1, j1 - 1);
        if (i1 + 1 < grid.size() && isHaveOne(grid, i1 + 1, j1))
            ChangeGrid(grid, next_grid, i1 + 1, j1);
        if (i1 - 1 >= 0 && isHaveOne(grid, i1 - 1, j1))
            ChangeGrid(grid, next_grid, i1 - 1, j1);
    }

    int solve(vector<vector<char>>& grid)
    {
        vector<vector<char>> next_grid(grid);
        int ret = 0;
        for (int i = 0; i < grid.size(); ++i)
        {
            for (int j = 0; j < grid[0].size(); ++j)
            {
                if (grid[i][j] == '1')
                {
                    ++ret;
                    ChangeGrid(grid, next_grid, i, j);
                }
            }
        }
        return ret;
    }
};

int main2()
{
    vector<vector<char>> grid({ {'1','1','0','0','0'},
                                {'0','1','0','1','1'},
                                {'0','0','0','1','1'},
                                {'0','0','0','0','0'},
                                {'0','0','1','1','1'}});
    cout << Solution().solve(grid) << endl;

    return 0;
}

int main1()
{
    string str;
    cin >> str;
    string ret;

    int n = str.size(), begin = 0, len = 0;
    for (int left = 0, right = 0; right < n; ++right)
    {
        char in = str[right];
        int flag = 0;
        if (isdigit(in))
        {
            left = right;
            flag = 1;
            while (right < n && isdigit(str[right]))
            {
                ++right;
            }
        }
        
        if (flag == 1)
        {
            if (right - left > len)
            {
                begin = left;
                len = right - left;
            }
        }
    }
    ret = str.substr(begin, len);
    cout << ret << endl;

    return 0;
}